Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

core/data/src/commonMain/kotlin/org/meshtastic/core/data/datasource/BundledAssetReader.kt 2d20cd8a4708e2ef66e98d5259f3a97ec93f240a (2d20cd8a) Text, 1.81 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.data.datasource

Tff7b72import T7ee787kotlinx.serialization.ExperimentalSerializationApi
Tff7b72import T7ee787kotlinx.serialization.json.Json
Tff7b72import T7ee787kotlinx.serialization.json.okio.decodeFromBufferedSource
Tff7b72import T7ee787okio.Source
Tff7b72import T7ee787okio.buffer

T8b949e/**
* Reads a bundled JSON asset by file name. Android serves these from `assets/`; non-Android targets have no bundled
* assets and return `null`, which callers treat as "nothing to seed".
*/
Tff7b72fun Tff7b72interface T56d364BundledAssetReader Tb4b4b4{
T8b949e/** Opens [name] (e.g. `"device_links.json"`), or returns `null` if the asset is absent. */
Tff7b72fun Td2a8ffopenTb4b4b4(Te6edf3nameTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Te6edf3Source?
Tb4b4b4}

T8b949e/** Decodes bundled asset [name] to [T] using the shared tolerant [json], or `null` if the asset is absent. */
Tf0883e@OptInTb4b4b4(Te6edf3ExperimentalSerializationApiTff7b72::Te6edf3classTb4b4b4)
Tff7b72inline Tff7b72fun Tff7b72<Tff7b72reified Te6edf3TTff7b72> Te6edf3BundledAssetReaderTb4b4b4.Td2a8ffdecodeTb4b4b4(Te6edf3nameTb4b4b4: Tffa657StringTb4b4b4, Te6edf3jsonTb4b4b4: Te6edf3JsonTb4b4b4)Tb4b4b4: Te6edf3T? Tb4b4b4{
T8b949e// okio.Source doesn't extend AutoCloseable in commonMain, so close explicitly instead of `use {}`.
Tff7b72val Te6edf3source Tff7b72= Tb4b4b4(Te6edf3openTb4b4b4(Te6edf3nameTb4b4b4) Tff7b72?: Tff7b72return Tff7b72nullTb4b4b4)Tb4b4b4.Te6edf3bufferTb4b4b4(Tb4b4b4)
Tff7b72return Tff7b72try Tb4b4b4{
Te6edf3jsonTb4b4b4.Te6edf3decodeFromBufferedSourceTb4b4b4(Te6edf3sourceTb4b4b4)
Tb4b4b4} Tff7b72finally Tb4b4b4{
Te6edf3sourceTb4b4b4.Te6edf3closeTb4b4b4(Tb4b4b4)
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.04s